﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace GraphDrawer {
	public partial class ExportModel : UserControl {
		public event RoutedEventHandler Closed;
		public event RoutedEventHandler OK;
		
		public ExportModel() {
			InitializeComponent();

			Closed += new RoutedEventHandler(ExportModel_Closed);
			OK += new RoutedEventHandler(ExportModel_OK);
		}

		void ExportModel_Closed(object sender, RoutedEventArgs e) {
			Visibility = Visibility.Collapsed; 
		}

		void ExportModel_OK(object sender, RoutedEventArgs e) {
			Visibility = Visibility.Collapsed; 
		}

		private void Name_TextChanged(object sender, TextChangedEventArgs e) {
			if (name.Text.Length > 0)
				ok.IsEnabled = true;
			else ok.IsEnabled = false;
		}

		private void Close_Click(object sender, RoutedEventArgs e) {
			Closed.Invoke(sender, e);
		}

		private void OK_Click(object sender, RoutedEventArgs e) {
			DataProvider.DataProviderServiceSoapClient cl = new DataProvider.DataProviderServiceSoapClient();
			cl.SetDiseaseAsync(name.Text, ((ModelEditor)((Canvas)Parent).Parent).GraphML, description.Text);
			
			OK.Invoke(this, e);
		}
	}
}
